<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Crypt;
use DB;
class SecurityController extends Controller
{
    
    public function changepassword() {
        return view('home.profile.security.changepassword');
    }
    
    //修改密码
    public function dochange(Request $request)
    {
    	// dd($request);
    	$data = $request -> only('password','id');
        //处理数据
        $data['password'] = Crypt::encrypt($data['password']);

        $res = DB::table('users') -> where('id', $data['id']) -> update($data);

        if($res)
        {
            return redirect('profile/security/changepassword') -> with(['info' => '修改密码成功']);
        }else
        {
            return back() -> with(['info' => '修改密码失败']);
        }
    }
}
